<template>
	<div class="mortgage-statistic page_pos_style" :style="{ top: `${phoneStatusBarHeight}`}">
		<!-- <van-nav-bar title="按揭意向统计" fixed placeholder :border='false'>
			<template #left>
				<van-icon
				name="arrow-left"
				size="18"
				@click="goback()"
				/>
			</template>
		</van-nav-bar> -->
    
    <navbar :title="title" style="margin: -16px -16px 16px -16px;"></navbar>
		<find-time :statisticsData='statisticsData'></find-time>
		<div class="chart">
			<div class="line-chart-box">
				<line-chart></line-chart>
			</div>
		</div>
	</div>
</template>

<script>
	import findTime from '../../components/common/findTime.vue'
	import lineChart from '../../components/common/lineChart.vue'
	import { getMortgageSta1 } from './api'
	export default {
		components: {
			findTime,
			lineChart
		},
		data() {
			return {
        // header栏 => 标题
        title:"按揭意向统计",
				statisticsData: [
					{'statistics': '本年度按揭次数', 'num': 976},
					{'statistics': '本季度按揭次数', 'num': 976},
					{'statistics': '本月按揭次数', 'num': 976},
					{'statistics': '本周按揭次数', 'num': 976}
				],
        // 获取屏幕状态栏高度
        phoneStatusBarHeight:''
			}
		},
		methods: {
			goback() {
        this.$router.go(-1)
      },
			// 获取统计数据1
			async getS1Data() {
				const {data} = await getMortgageSta1()
				console.log(data)
				// console.log(data)
				this.statisticsData[0].num = data.yearCount
				this.statisticsData[1].num = data.quarterCount
				this.statisticsData[2].num = data.monthCount
				this.statisticsData[3].num = data.weekCount
			},
      // 获取路由链接上拼接的token值
      getTokenInUrl() {
        var url = window.location.href;
        if (url.indexOf("token") > 0) {
          let getTokenParams = window.location.href.split("token=")[1];
          getTokenParams=getTokenParams.split("&")[0];
          if (getTokenParams.length >= 32) {
            getTokenParams = getTokenParams.substr(0, 32);
            console.log('%c [ getTokenParams ]', 'font-size:13px; background:pink; color:#bf2c9f;', getTokenParams)
            sessionStorage.setItem("token", getTokenParams);
          }
        }
      }
		},
		mounted() {
      document.querySelector('body').setAttribute('style', 'background-color:#F8F8F8')
    },
		created() {
      // 获取屏幕状态栏高度
      this.phoneStatusBarHeight = window.phoneStatusBarHeight
      // 修改页面标题
      document.title = "按揭意向统计"
      // 获取路由链接上拼接的token值
      this.getTokenInUrl()
			this.getS1Data()
		}
	}
</script>

<style scoped lang="less">
	.mortgage-statistic{
		margin: 16px;
	}
	.chart{
		margin-top: 16px;
	}
</style>
